package com.googlecode.hessianserver.example;

import com.googlecode.hessianserver.HessianServer;
import com.googlecode.hessianserver.HessianServiceDefinition;
import com.googlecode.hessianserver.example.api.Calculator;
import com.googlecode.hessianserver.example.impl.CalculatorImpl;

/**
 * Creates a new <code>HessianServer</code> with example services ready to
 * accept connections from hessian clients
 *
 * @author rayvanderborght
 */
public class ExampleServer
{
	/**
	 * Demonstrates server side setup of <code>HessianServer</code>
	 *
	 * @param args
	 * @throws Exception
	 */
	public static void main(String[] args) throws Exception
	{
		HessianServiceDefinition calculatorService = new HessianServiceDefinition("/calculatorService", new CalculatorImpl(), Calculator.class);
		HessianServer hessianServer = new HessianServer(9090, calculatorService);
		hessianServer.start();

		System.out.println("HessianServer started. Use 'x' to quit");
		while (System.in.read() != 'x')
		{
			// keep reading until 'x' is entered
		}

		hessianServer.stop();
	}
}
